﻿using System;
using System.Collections.Generic;
using System.Collections.ObjectModel;

namespace MessagingWPF.Infrastructure
{
	/// <summary>
	/// A cache of message subscription interests.
	/// </summary>
	public interface IMessageInterestCache
	{
		/// <summary>
		/// Adds the subscription interests to the cache.
		/// </summary>
		/// <param name="subscriberType">
		/// The subscriber type.
		/// </param>
		/// <param name="messageTypes">
		/// A collection of types of messages the subscriber is interested in.
		/// </param>
		/// <exception cref="ArgumentNullException">
		/// Thrown when one of the parameters is <c>null</c>
		/// </exception>
		void Add(Type subscriberType, IEnumerable<Type> messageTypes);

		/// <summary>
		/// Returns all the interests of the specified type.
		/// </summary>
		/// <param name="subscriberType">The type of the subscriber to check for.</param>
		/// <returns>
		/// A collection of types the specified subscriber type is interested in.
		/// </returns>
		/// <exception cref="ArgumentNullException">
		/// Thrown when <paramref name="subscriberType"/> is <c>null</c>
		/// </exception>
		bool Contains(Type subscriberType);

		/// <summary>
		/// Determines whether the specified type has known interests stored in the cache.
		/// </summary>
		/// <param name="subscriberType">The type of the subscriber to check for.</param>
		/// <returns>
		/// <c>True</c> when the specified type has cached interests; otherwise <c>False</c>.
		/// </returns>
		/// <exception cref="ArgumentNullException">
		/// Thrown when <paramref name="subscriberType"/> is <c>null</c>
		/// </exception>
		ReadOnlyCollection<Type> Get(Type subscriberType);
	}
}